package com.web.oa.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
public class CheckCodeController {
    @RequestMapping("/checkCode")
    public void checkCode(HttpSession session, HttpServletResponse resp){
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(80, 33,4,10);
        //存入session
        session.setAttribute("right",lineCaptcha.getCode());
        try {
            lineCaptcha.write(resp.getOutputStream());
        } catch (IOException exception) {
            exception.printStackTrace();
        }
    }
}
